import {Button} from "antd";
import {LeftOutlined} from "@ant-design/icons";
import {useNavigate} from "react-router-dom";

/**
 * 返回上级按钮
 *
 * @param props
 * message: 按钮中现实的文字
 * backToLink: 返回的链接
 */
const BackButton = (props) => {

    const {
        message,    // 按钮中的文字
        backToLink  // 跳转连接
    }
        = props;
    const navigate = useNavigate();

    return (
        <Button
            type="primary"
            icon={<LeftOutlined/>}
            size="middle"
            style={{
                marginBottom: 16,
                padding: "6px 16px",
                transition: "all 0.2s",
            }}
            onClick={() => navigate(backToLink)}
        >
            {message}
        </Button>
    )
}

export default BackButton;